/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tcc.ejb.controleProjeto.entidade;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Maciel
 */
@Entity
@Table(name = "item_artefato", catalog = "macielqs", schema = "controleprojeto")
@NamedQueries({
    @NamedQuery(name = "ItemArtefato.findAll", query = "SELECT i FROM ItemArtefato i"),
    @NamedQuery(name = "ItemArtefato.findById", query = "SELECT i FROM ItemArtefato i WHERE i.id = :id"),
    @NamedQuery(name = "ItemArtefato.findByNome", query = "SELECT i FROM ItemArtefato i WHERE i.nome = :nome"),
    @NamedQuery(name = "ItemArtefato.findByDescricao", query = "SELECT i FROM ItemArtefato i WHERE i.descricao = :descricao")})
public class ItemArtefato implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id", nullable = false)
    private Integer id;
    @Basic(optional = false)
    @Column(name = "nome", nullable = false, length = 25)
    private String nome;
    @Basic(optional = false)
    @Column(name = "descricao", nullable = false, length = 2147483647)
    private String descricao;
    @ManyToMany(mappedBy = "itemArtefatoList")
    private List<Artefato> artefatoList;
    @JoinColumn(name = "tipo_artefato_id", referencedColumnName = "id", nullable = false)
    @ManyToOne(optional = false)
    private TipoArtefato tipoArtefato;

    public ItemArtefato() {
    }

    public ItemArtefato(Integer id) {
        this.id = id;
    }

    public ItemArtefato(Integer id, String nome, String descricao) {
        this.id = id;
        this.nome = nome;
        this.descricao = descricao;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public String getDescricao() {
        return descricao;
    }

    public void setDescricao(String descricao) {
        this.descricao = descricao;
    }

    public List<Artefato> getArtefatoList() {
        return artefatoList;
    }

    public void setArtefatoList(List<Artefato> artefatoList) {
        this.artefatoList = artefatoList;
    }

    public TipoArtefato getTipoArtefato() {
        return tipoArtefato;
    }

    public void setTipoArtefato(TipoArtefato tipoArtefato) {
        this.tipoArtefato = tipoArtefato;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ItemArtefato)) {
            return false;
        }
        ItemArtefato other = (ItemArtefato) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "tcc.ejb.controleProjeto.entidade.ItemArtefato[id=" + id + "]";
    }

}
